package com.ibm.psbc.cloud.sample;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
public class SimpleSourceBean {
	@Autowired
	private Source source;

	private static final Logger logger = LoggerFactory.getLogger(SimpleSourceBean.class);

	public void publishOrgChannel(String action,String orgId){
		logger.debug("Sending Kafka message {} for Organization Id: {}", action, orgId);
		TestModel change = new TestModel(action, orgId);
		source.output().send(MessageBuilder.withPayload(change).build());
	}
}
